New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hast-util-from-string

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hast-util-from-string

hast utility to set the plain-text value of a node

  • 1.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
20K
decreased by-5.96%
Maintainers
2
Weekly downloads
 
Created
Source

hast-util-from-string

Build Coverage Downloads Size Sponsors Backers Chat

Set the plain-text value of a hast node. This is like the DOMs Node#textContent setter. The given node is returned.

Install

npm:

npm install hast-util-from-string

Use

var h = require('hastscript')
var fromString = require('hast-util-from-string')

fromString(h('p'), 'Alpha')
// { type: 'element',
//   tagName: 'p',
//   properties: {},
//   children: [ { type: 'text', value: 'Alpha' } ] }
fromString(h('div', [h('b', 'Bold'), ' and ', h('i', 'italic'), '.']), 'Charlie')
// { type: 'element',
//   tagName: 'div',
//   properties: {},
//   children: [ { type: 'text', value: 'Charlie' } ] }

API

fromString(node[, value])

If node is a text node (has a value property), set that to the given value or an empty string. If node is a parent node (has children), replace them with a text node whose data is set to the given value, or if value is not given, remove all its children.

Contribute

See contributing.md in rehypejs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Keywords

FAQs

Package last updated on 02 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc